package com.example.chat.controller;

import com.dragonsoftbravo.libs.Opr;
import com.example.chat.model.ro.RoleRO;
import com.example.chat.model.vo.ValidatedGroup;
import com.example.chat.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description
 * @Date 2022/11/17 10:05
 * @Author pq
 */
@RestController
@Api(value = "角色管理",tags = {"角色管理"})
@RequestMapping("/role")
public class RoleController extends BaseController {

    @Resource
    private RoleService roleService;

    @ApiOperation(value = "新增/修改角色权限")
    @PostMapping("/update")
    public ResponseEntity<Opr<Void>> updateRole(@Validated(value = ValidatedGroup.Delete.class) @RequestBody RoleRO ro, BindingResult br) {
        roleService.updateRole(ro);
        validateFiled(br);
        return this.process(this::successResult);
    }
}
